package gao.xiaolei.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import gao.xiaolei.dto.Task;
import gao.xiaolei.dto.TaskInDto;
import gao.xiaolei.util.ServiceName;
import java.util.List;

@Service("CreateNoticeTaskService")
public class CreateNoticeTaskService {

    @Autowired
    private RestTemplate restTemplate;

    //根据任务内容创建任务
    public void createNoticeTask(Task task,List<String> receiverList){
        HttpHeaders headers=new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
        HttpEntity<TaskInDto> httpEntity=new HttpEntity<>(new TaskInDto(task,receiverList),headers);
        restTemplate.postForObject(ServiceName.TASK_SERVICE.getServiceName(),httpEntity,Object.class);
    }

}
